<template>
  <div>
    <div class="top">
      <div class="left" id="left"></div>
      <div class="right" id="right"></div>
    </div>
    <div class="bottom" id="bottom"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      key: value,
    };
  },
  methods: {
    // left
    getLeft() {
      var myChart = echarts.init(document.getElementById("left"));
      myChart.setOption({
        title: {
          text: "爱尔眼科用户年龄段统计",
        },
        tooltip: {},
        xAxis: {
          data: [
            "10岁以下",
            "20岁以下",
            "30岁以下",
            "40岁以下",
            "50岁以下",
            "60岁以上",
          ],
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "bar",
            data: [5, 20, 36, 10, 10, 20],
          },
        ],
      });
    },

    // right
    getRight() {
      var myChart = echarts.init(document.getElementById("right"));
      myChart.setOption({
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      });
    },

    // bottom
    getBottom() {
      var myChart = echarts.init(document.getElementById("bottom"));
      myChart.setOption({
        title: {
          text: "Referer of a Website",
          subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      });
    },
  },
  mounted() {
    this.getLeft();
    this.getRight();
    this.getBottom();
  },
};
</script>

<style lang="scss" scoped>
.top {
  display: flex;
  justify-content: space-between;
  .left,
  .right {
    background-color: #eee;
    width: 49%;
    height: 420px;
  }
}
.bottom {
  margin-top: 20px;
  background-color: #eee;
  height: 420px;
}
</style>